package main;

/**
 * contains the political system info
 * @author Bart Machielse and Justin Yu
 *
 */
public class PoliticalSystem {

	private Player Owner;
	private double lib;
	private double soc;
	
	/**
	 * base constructor
	 * @param o owner
	 */
	public PoliticalSystem(Player o){
		Owner=o;
		lib=5;
		soc=5;
	}
	
	/**
	 * method to icnrement turn
	 * no parameters
	 */
	public void incrementTurn(){
		lib=.95 *lib + .1*Math.random()*lib;
		soc=.95 *soc + .1*Math.random()*soc; //both of these are subject to random drift
		double average=(lib+soc)/2;
		lib=lib+(average-lib)/5;//arbitrary value moving towards each other by a certain amount
		soc=soc+(average-soc)/8;//arbitrary value
		if(lib>10.0)
			lib=10;
		if(soc>10.0)
			soc=10;
		if(lib<0)
			lib=0;
		if(soc<0)
			soc=0;
	}


	/**
	 * @return the lib
	 */
	public double getLib() {
		return lib;
	}


	/**
	 * @param lib the lib to set
	 */
	public void setLib(double lib) {
		Owner.getRes().setHappiness((int)(Owner.getRes().getHappiness()-Math.abs(this.lib-lib)));
		this.lib = lib;
	}//changing lib costs happiness


	/**
	 * @return the soc
	 */
	public double getSoc() {
		return soc;
	}


	/**
	 * @param soc the soc to set
	 */
	public void setSoc(double soc) {
		Owner.getRes().setHappiness((int)(Owner.getRes().getHappiness()-2*Math.abs(this.soc-soc)));
		this.soc = soc;
	}//it costs more to change social culture than governmental culture
	

}
